import {controller,get} from './../lib/decorator'

import {getAllMovies,getMovieDetail,getAllType} from './../service/movie'
@controller('/api/v0/movies')
export class movieController{
    @get('/')
    async getMovies (ctx,next){
        const {type}=ctx.query
        const movies=await getAllMovies(type)
      
        ctx.body={
            success:true,
            data:movies
        }
    }
    @get('/type')
    async getType(ctx,next){
        const types=await getAllType()
        ctx.body={
            success:true,
            data:types
        }
    }
    @get('/:id')
    async getDetail(ctx,next){
        const id=ctx.params.id
        const movie=await getMovieDetail(id)
        ctx.body={
            success:true,
            data:movie
        }
    }
  
}